package com.wu01.demo.config;


import com.wu01.demo.component.CustomLocaleResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.Locale;

@Configuration
public class WebMvcSupportConfig extends WebMvcConfigurationSupport {

    /**
     * 配置静态资源
     * @param registry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/");
        super.addResourceHandlers(registry);
    }

    @Override
    public LocaleResolver localeResolver() {
        return new CustomLocaleResolver();
    }
}